﻿<UserControl 
    x:Class="FU.Capstones.IMS.Web.Silverlight.Views.WarehouseDetail"
	xmlns:Navigation="clr-namespace:Navigation.Silverlight;assembly=Navigation.Silverlight" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
    xmlns:Controls="clr-namespace:FU.Capstones.IMS.Web.Silverlight.Controls" 
    xmlns:TControls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" 
	xmlns:DControls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Data" 
    xmlns:telerikGrid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView" 
    xmlns:Common="clr-namespace:FU.Capstones.IMS.Web.Common;assembly=FU.Capstones.IMS.Web.Common"
    Navigation:ViewModel.TypeName="FU.Capstones.IMS.Web.Silverlight.ViewModels.WarehouseDetailViewModel">

    <UserControl.Resources>
        <Common:DataContextProxy x:Key="DataContextProxy"/>
    </UserControl.Resources>

    <telerik:RadBusyIndicator
        BusyContent="Đang kết nối tới máy chủ..."
        IsBusy="{Binding Path=ServiceCallCounter, Converter={StaticResource IntegerToBoolConverter}}"
        >
        <Grid x:Name="LayoutRoot" Style="{StaticResource ViewGridStyle}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="10"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="10"/>
            </Grid.RowDefinitions>
            <!--Title-->
            <Grid Grid.ColumnSpan="4">
                <Grid.Background>
                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                        <GradientStop Color="{StaticResource OuterColor}" Offset="{StaticResource ControlBackgroundGradientStop0}"/>
                        <GradientStop Color="{StaticResource InnerColor}" Offset="{StaticResource ControlBackgroundGradientStop1}"/>
                        <GradientStop Color="{StaticResource InnerColor}" Offset="{StaticResource ControlBackgroundGradientStop2}"/>
                        <GradientStop Color="{StaticResource OuterColor}" Offset="{StaticResource ControlBackgroundGradientStop3}"/>
                    </LinearGradientBrush>
                </Grid.Background>

                <TextBlock 
                    x:Name="lblTitle" 
                    Style="{StaticResource TextBlockTitlePageStyle}"                   
                    Text="Thông tin kho"/>
            </Grid>

            <TControls:RadTabControl                
                Grid.Row="2"  Grid.Column="0" Grid.ColumnSpan="3"
                Background="Transparent"
                >
                <TControls:RadTabItem
                    Header="Thông tin chung"
                    Background="Transparent"
					IsSelected="True"
                    >
                    <Grid Grid.Column="1" Grid.Row="2" >
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="5" />
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>

                        <!--Name-->
                        <TextBlock
                            Style="{StaticResource TextBlockNormalStyle}"
                            Grid.Column="1" Grid.Row="0">
                            <Run Text="{StaticResource WarehouseNameText}" />
                            <Run Foreground="Red" Text="*" />
                        </TextBlock>

                        <TextBox 
                            x:Name="txtWarehouseName"
                            Style="{StaticResource TextBoxNormalStyle}"
                            Grid.Column="2" Grid.Row="0"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
                            Text="{Binding Path=Warehouse.WarehouseName, Mode=Twoway, ValidatesOnDataErrors=True}"
                        />

                        <!--Tel-->
                        <TextBlock
                            Style="{StaticResource TextBlockNormalStyle}"
                            Grid.Column="1" Grid.Row="1">
                            <Run Text="{StaticResource TelephoneNumText}" />
                            <Run Foreground="Red" Text="*" />
                        </TextBlock>
                        <TextBox 
                            x:Name="txtWarehouseTelephoneNum"
                            Style="{StaticResource TextBoxNormalStyle}"
                            Grid.Column="2" Grid.Row="1"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
                            Text="{Binding Path=Warehouse.OfficePhone, Mode=Twoway, ValidatesOnDataErrors=True}"
                            />

                        <!--Person in charge-->
                        <TextBlock
                            Style="{StaticResource TextBlockNormalStyle}"
                            Grid.Column="1" Grid.Row="2">
                            <Run Text="{StaticResource PersonInChargeText}" />
                            <Run Foreground="Red" Text="*" />
                        </TextBlock>
                        <ComboBox
                            Grid.Column="2" Grid.Row="2"
                            Style="{StaticResource ComboBoxNormalStyle}"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
                            ItemsSource="{Binding Path=EmployeeCollection, Mode=TwoWay}"
							DisplayMemberPath="FullName"
                            SelectedItem="{Binding Path=Warehouse.Manager, Mode=TwoWay, ValidatesOnDataErrors=True}"
                            />

                        <!--Address-->
                        <TextBlock
                            Style="{StaticResource TextBlockNormalStyle}"
                            Grid.Column="1" Grid.Row="3">
                            <Run Text="{StaticResource AddressText}" />
                            <Run Foreground="Red" Text="*" />
                        </TextBlock>
                        <TextBox 
                            x:Name="txtWarehouseAddress" 
                            Style="{StaticResource TextBoxNormalStyle}"
                            Grid.Column="2" Grid.Row="3"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
                            Text="{Binding Path=Warehouse.Address, Mode=TwoWay}"
                        />
                        <!--Description-->
                        <TextBlock
                            Style="{StaticResource TextBlockNormalStyle}"
                            Grid.Column="1" Grid.Row="4">
                            <Run Text="{StaticResource DescriptionText}" />
                        </TextBlock>
                        <TextBox 
                            x:Name="txtWarehouseDescription" 
                            Style="{StaticResource TextBoxMultilineStyle}"
                            Grid.Column="2" Grid.Row="4"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
                            Text="{Binding Path=Warehouse.Description, Mode=TwoWay}"
                        />
                        <!--Buttons-->
                        <!--<Controls:WarehouseDetailViewModeButton
                    Grid.Row="6" Grid.ColumnSpan="2"/>-->

                    </Grid>
                </TControls:RadTabItem>

                <TControls:RadTabItem
                    Header="Nguyên/vật liệu"
                    Background="Transparent"
					Visibility="{Binding Path=IsCreateNew, Mode=OneWay,Converter={StaticResource InverseBoolToVisibilityConverter}}"
					>
                    <Grid>
                    
						<Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto" />
							<RowDefinition Height="10" />
                            <RowDefinition Height="*"/>
                     	</Grid.RowDefinitions>
                     	<Grid.ColumnDefinitions>
                            <ColumnDefinition Width="10"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="10"/>
                     	</Grid.ColumnDefinitions>
						<telerikGrid:RadGridView
	                        x:Name="grdMaterial" 
	                        Grid.Row="4" Grid.Column="1" 
	                        telerik:StyleManager.Theme="Office_Black"
	                        Style="{StaticResource RadGridViewNormal}"
	                        ItemsSource="{Binding Path=MaterialCollection}"
	                        >
	                        <telerikGrid:RadGridView.Columns>

	                            <!--<telerikGrid:GridViewDataColumn 
	                                Header="{StaticResource MaterialCodeLabelText}"
	                                Width="100" HeaderTextAlignment="Center">
	                                <telerikGrid:GridViewDataColumn.CellTemplate>
	                                    <DataTemplate>
	                                        <HyperlinkButton 
	                                            Content="{Binding Path=MaterialCode}"  
	                                            Command="{Binding Path=DataSource.EditCommand, Source={StaticResource DataContextProxy}}"
	                                            CommandParameter="{Binding Path=MaterialID}"
	                                        />
	                                    </DataTemplate>
	                                </telerikGrid:GridViewDataColumn.CellTemplate>
	                            </telerikGrid:GridViewDataColumn>-->
								
								<telerikGrid:GridViewDataColumn 
	                                Header="{StaticResource MaterialCodeLabelText}"
	                                Width="100" HeaderTextAlignment="Center"
	                                DataMemberBinding="{Binding Path=MaterialCode}"
	                            />

	                            <telerikGrid:GridViewDataColumn 
	                                Header="{StaticResource MaterialNameLabelText}"
	                                Width="150" HeaderTextAlignment="Center"
	                                DataMemberBinding="{Binding Path=MaterialName}"
	                            />

	                            <telerikGrid:GridViewDataColumn 
	                                Header="{StaticResource BriefDescriptionLabelText}"
	                                Width="250" HeaderTextAlignment="Center"
	                                DataMemberBinding="{Binding Path=Description}"
	                            />
								
								<telerikGrid:GridViewDataColumn 
	                                Header="{StaticResource TotalQuantityLabelText}"
	                                Width="100" HeaderTextAlignment="Center"
	                                DataMemberBinding="{Binding Path=Quantity}"
	                            />
	                        </telerikGrid:RadGridView.Columns>
	                    </telerikGrid:RadGridView>
						
						<Grid
							Grid.Row="5" Grid.Column="1">
							
							<DControls:RadDataPager
			                    x:Name="DataPager"
			                    Source="{Binding Path=MaterialCollection}"
			                    Style="{StaticResource DataPagerNormalStyle}"
			                    />
							
						</Grid>
					</Grid>
					
                </TControls:RadTabItem>

                <TControls:RadTabItem
                    Header="Thành phẩm"
                    Background="Transparent"
					Visibility="{Binding Path=IsCreateNew, Mode=OneWay,Converter={StaticResource InverseBoolToVisibilityConverter}}"
					>
                	
                    <!--GridView-->
					<Grid>
						<Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto" />
							<RowDefinition Height="10" />
                            <RowDefinition Height="*"/>
                     	</Grid.RowDefinitions>
                     	<Grid.ColumnDefinitions>
                            <ColumnDefinition Width="10"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="10"/>
                     	</Grid.ColumnDefinitions>
	                    <telerikGrid:RadGridView
	                        x:Name="GridView"
	                        Grid.Row="4" Grid.Column="1"
	                        telerik:StyleManager.Theme="Office_Black"
	                        Style="{StaticResource RadGridViewNormal}"
	                        ItemsSource="{Binding Path=ProductCollection}"
	                        >
	                        <telerikGrid:RadGridView.Columns>
	                            <!--<telerikGrid:GridViewColumn
	                                Header="{StaticResource ProductCodeLabelText}"
	                                Width="100" HeaderTextAlignment="Center">
	                                <telerikGrid:GridViewColumn.CellTemplate>
	                                    <DataTemplate>
	                                        <HyperlinkButton 
	                                            Content="{Binding Path=ProductCode}"  
	                                            Command="{Binding Path=DataSource.EditCommand, Source={StaticResource DataContextProxy}}"
	                                            CommandParameter="{Binding Path=ProductID}"
	                                        />
	                                    </DataTemplate>
	                                </telerikGrid:GridViewColumn.CellTemplate>
	                            </telerikGrid:GridViewColumn>-->

	                            <telerikGrid:GridViewDataColumn 
	                                Header="{StaticResource ProductCodeLabelText}"
	                                Width="100" HeaderTextAlignment="Center"
	                                DataMemberBinding="{Binding Path=ProductCode}"
	                            />

								
								<telerikGrid:GridViewDataColumn 
	                                Header="{StaticResource ProductNameLabelText}"
	                                Width="150" HeaderTextAlignment="Center"
	                                DataMemberBinding="{Binding Path=ProductName}"
	                            />

	                            <telerikGrid:GridViewDataColumn 
	                                Header="{StaticResource BriefDescriptionLabelText}"
	                                Width="250" HeaderTextAlignment="Center"
	                                DataMemberBinding="{Binding Path=Description}"
	                            />
								<telerikGrid:GridViewDataColumn 
	                                Header="{StaticResource TotalQuantityLabelText}"
	                                Width="100" HeaderTextAlignment="Center"
	                                DataMemberBinding="{Binding Path=Quantity}"
	                            />
	                        </telerikGrid:RadGridView.Columns>
	                    </telerikGrid:RadGridView>
						<Grid 
							Grid.Row="5" Grid.Column="1">
								
							<DControls:RadDataPager
				            	x:Name="DataPager2"
				                Source="{Binding Path=ProductCollection}"
				                Style="{StaticResource DataPagerNormalStyle}"
				                />
								
						</Grid>
					</Grid>
					
                </TControls:RadTabItem>

                <TControls:RadTabItem
                    Header="Lịch sử nhập/xuất"
                    Background="Transparent"
					Visibility="Collapsed">
                	<Grid>
	                    <telerikGrid:RadGridView 
	                        telerik:StyleManager.Theme="Office_Black"
	                        Style="{StaticResource RadGridViewNormal}"
	                        ItemsSource="{Binding Path=OrderCollection,Mode=TwoWay}"
	                        Grid.Row="4" Grid.Column="1" >

	                        <telerikGrid:RadGridView.Columns>

	                            <telerikGrid:GridViewDataColumn 
	                                Header="Mã Đơn Hàng"
	                                Width="100" HeaderTextAlignment="Center">
	                                <telerikGrid:GridViewDataColumn.CellTemplate>
	                                    <DataTemplate>
	                                        <HyperlinkButton 
	                                            Content="{Binding Path=OrderCode}"  
	                                            Command="{Binding Path=DataSource.EditOrderCommand, Source={StaticResource DataContextProxy}}"
	                                            CommandParameter="{Binding Path=OrderID}"
	                                        />
	                                    </DataTemplate>
	                                </telerikGrid:GridViewDataColumn.CellTemplate>
	                            </telerikGrid:GridViewDataColumn>

	                            <telerikGrid:GridViewDataColumn 
	                                DataMemberBinding="{Binding Path=OrderDate}"
	                                Header="Ngày tạo"
	                                Width="140" HeaderTextAlignment="Center"
	                            />

	                            <telerikGrid:GridViewDataColumn 
	                                DataMemberBinding="{Binding Path=EmployeeA.EmployeeID}"
	                                Header="Người làm"
	                                Width="150" HeaderTextAlignment="Center"
	                            />

	                            <telerikGrid:GridViewDataColumn 
	                                DataMemberBinding="{Binding Path=IsImported}"
	                                Header="Kiểu hóa đơn"
	                                Width="100" HeaderTextAlignment="Center"
	                            />

	                            <telerikGrid:GridViewDataColumn 
	                                DataMemberBinding="{Binding Path=Contact.ContactID}"
	                                Header="Bên B"
	                                Width="150" HeaderTextAlignment="Center"
	                            />

	                        </telerikGrid:RadGridView.Columns>
	                    </telerikGrid:RadGridView>
						<Grid 
							Grid.Row="5" Grid.Column="1">
								
							<DControls:RadDataPager
				            	x:Name="DataPager3"
				                Source="{Binding Path=Warehouse.ProductCollection, Mode=TwoWay}"
				                Style="{StaticResource DataPagerNormalStyle}"
				                />
								
						</Grid>
					</Grid>
                </TControls:RadTabItem>

            </TControls:RadTabControl>

            <!--Message-->
            <TextBlock
                HorizontalAlignment="Center"
                Grid.Column="0" Grid.Row="4" Grid.ColumnSpan="4"
                Style="{StaticResource ErrorMessageTextBlockStyle}"
                Text="{Binding Path=Message, Mode=TwoWay}"
                Visibility="{Binding Path=ErrorMessageVisibility, Mode=TwoWay}"
            />

            <TextBlock
                HorizontalAlignment="Center"
                Grid.Column="0" Grid.Row="4" Grid.ColumnSpan="3"
                Style="{StaticResource SuccessfulMessageTextBlockStyle}"
                Text="{Binding Path=Message, Mode=TwoWay}"
                Visibility="{Binding Path=MessageVisibility, Mode=TwoWay}"
                />

            <StackPanel
                Orientation="Horizontal" HorizontalAlignment="Center"
                Grid.Column="0" Grid.Row="5" Grid.ColumnSpan="3">
                <!--Buttons-->
                <Controls:SaveButtonControl 
                    Visibility ="{Binding Path=CanEditOrAdd, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
                    />

                <Controls:ResetButtonControl 
                    Visibility ="{Binding Path=CanEditOrAdd, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
                    />

                <Controls:BackButtonControl
                    />
            </StackPanel>
        </Grid>
    </telerik:RadBusyIndicator>
</UserControl>
